package com.test.platform.dao;

import com.test.platform.model.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM users WHERE username = #{username}")
    User findByUsername(String username);

    @Insert("INSERT INTO users (username, password, salt, email, create_time, enabled, role) " +
            "VALUES (#{username}, #{password}, #{salt}, #{email}, #{createTime}, #{enabled}, #{role})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(User user);

    @Update("UPDATE users SET last_login_time = #{lastLoginTime} WHERE id = #{id}")
    int updateLastLoginTime(User user);
}